home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / bcrt.zip / BIOSCRT.PAS next >
Pascal/Delphi Source File  |  1988-08-29  |  22KB  |  556 lines

  1.  
  2. { -********************************************************************** -}
  3. {  BIOSCRT - A unit to allow text output through the standard BIOS calls   }
  4. {  This unit will work in both text and graphics modes. It was primarily   }
  5. {  written to allow use of the MS-DOS system font in graphics mode to      }
  6. {  compensate for the current lack of a BGI system font. Note: This method }
  7. {  will *NOT* work with most Hercules boards because they don't properly   }
  8. {  support the BIOS calls in graphics mode.                                }
  9. {                                                                          }
  10. {  Notes: If you are using this unit on a CGA in the graphics mode, you    }
  11. {  should run the GRAFTABL program from your DOS supplimental program disk }
  12. {  (this loads the extended CGA charater set into memory).                 }
  13. {                                                                          }
  14. {  To make this into a fully operational CRT type unit you will need to    }
  15. {  obtain a copy of Carley Phillips' "CRTI" unit which can be found on     }
  16. {  CompuServe in the Borland BPROGA Turbo library (DL2). Carley's CRTI     }
  17. {  unit will provide you with the sound, delay, and keyboard procedures.   }
  18. {                                                                          }
  19. {     Written by Michael Day 23 August 1988  CIS:[73577,2225]              }
  20. {     Updated to Version 2.0 and renamed to BiosCrt 29 August 1988         }
  21. {     This unit is released to the public domain by the author             }
  22. {     Mike Day    UUCP:...!tektronix!reed!qiclab!bakwatr!mikeday           }
  23. {     Chief Bit Washer, Day Research, P.O. Box 22902, Milwaukie, OR 97222  }
  24. {     Plans?...We don't need no stinkin' plans!                            }
  25. { -********************************************************************** -}
  26.  
  27. Unit  BiosCrt;
  28.  
  29. interface
  30. uses Dos;
  31.  
  32. var BiosWriteMode   : byte;      {Bios write mode to use for TFDD}
  33.     BiosTextAttr    : byte;      {Bios text attribute byte}
  34.     BiosStartAttr   : byte;      {Original startup attr}
  35.     LastBiosMode    : byte;      {last Bios screen mode in use}
  36.     LastBiosWidth   : byte;      {last Bios screen width used}
  37.     LastBiosPage    : byte;      {last Bios screen page used}
  38.  
  39. {--------------------------------------------------------------------------}
  40. {-- Below are listed the important Bios variables for the video display. --}
  41. {-- These are set by the Bios and are provided for reading only.  Do not --}
  42. {-- change any of these values or irratic display operation will result. --}
  43.  
  44.     BiosMode      : byte absolute $0040:$0049; {Current bios video mode}
  45.     BiosMaxX      : word absolute $0040:$004A; {Text cols on display}
  46.     BiosCrtLength : word absolute $0040:$004C; {Crt buffer size in bytes}
  47.     BiosCursorPos : array [0..7] of word absolute $0040:0050; {Cursor pos}
  48.     BiosCursorMode: word absolute $0040:$0060; {Current cursor mode}
  49.     BiosActivePage: byte absolute $0040:$0062; {Current active video page}
  50.     BiosAddr6845  : word absolute $0040:$0063; {I/O address of controller}
  51.     Bios6845Mode  : byte absolute $0040:$0065; {Current 6845 mode value}
  52.     BiosPalette   : byte absolute $0040:$0066; {Current palette selected}
  53.     BiosMaxY      : byte absolute $0040:$0084; {Text rows on display -1}
  54.     BiosCharSize  : word absolute $0040:$0085; {Height of character cell}
  55.     BiosInfo      : byte absolute $0040:$0087; {Misc video control info}
  56.     BiosInfo3     : byte absolute $0040:$0087; {Display card switch info}
  57.     BiosFlags     : byte absolute $0040:$0087; {Misc video control flags}
  58.     BiosDCC       : byte absolute $0040:$008A; {Display Combination Code}
  59.     BiosSavePtr   : pointer absolute $0040:$00A8; {Pointer to Bios save area}
  60.     BiosFontTable : byte absolute $F000:$FA6E; {CGA (8x8) Bios font table}
  61.  
  62. {++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  63. {-- The following are the inline macros used to access the BIOS routines --}
  64.  
  65. function BiosWhereX:integer;                      {get current cursor X pos}
  66. inline(
  67.    $B7/$00     { mov BH,0}
  68.   /$B4/$03     { mov AH,3}
  69.   /$55         { push BP}
  70.   /$CD/$10     { int $10}
  71.   /$5D         { pop BP}
  72.   /$30/$E4     { xor AH,AH}
  73.   /$88/$D0);   { mov AL,DL}
  74.  
  75. function BiosWhereY:integer;                      {get current cursor Y pos}
  76. inline(
  77.    $B7/$00     { mov BH,0}
  78.   /$B4/$03     { mov AH,3}
  79.   /$55         { push BP}
  80.   /$CD/$10     { int $10}
  81.   /$5D         { pop BP}
  82.   /$30/$E4     { xor AH,AH}
  83.   /$88/$F0);   { mov AL,DH}
  84.  
  85. procedure BiosWhereXY(var X,Y:integer);         {get current cursor X,Y pos}
  86. inline(
  87.    $B7/$00       { mov BH,0}
  88.   /$B4/$03       { mov AH,3}
  89.   /$55           { push BP}
  90.   /$CD/$10       { int $10}
  91.   /$5D           { pop BP}
  92.   /$07           { pop ES}
  93.   /$5B           { pop BX}
  94.   /$26/$88/$37   { mov ES:[BX],DH}
  95.   /$07           { pop ES}
  96.   /$5B           { pop BX}
  97.   /$26/$88/$17); { mov ES:[BX],DL}
  98.  
  99.  
  100. procedure BiosGotoXY(X,Y:integer);            {move cursor to indicated X,Y}
  101. inline(
  102.    $58         { pop AX}
  103.   /$5A         { pop DX}
  104.   /$88/$C6     { mov DH,AL}
  105.   /$B7/$00     { mov BH,0}
  106.   /$B4/$02     { mov AH,2}
  107.   /$55         { push BP}
  108.   /$CD/$10     { int $10}
  109.   /$5D);       { pop BP}
  110.  
  111. procedure BiosTextColor(FColor:integer);         {Set text foreground color}
  112. inline(
  113.    $58                   { pop AX}
  114.   /$24/$0f               { and AL,$0F}
  115.   /$8A/$26/>BiosTextAttr { mov AH,[>BiosTextAttr]}
  116.   /$80/$E4/$F0           { and AH,$F0}
  117.   /$08/$E0               { or AL,AH}
  118.   /$A2/>BiosTextAttr);   { mov [>BiosTextAttr],AL}
  119.  
  120. procedure BiosTextBackGround(BColor:integer);    {Set text background color}
  121. inline(
  122.    $58                   { pop AX}
  123.   /$B1/$04               { mov CL,4}
  124.   /$D2/$E0               { shl AL,CL}
  125.   /$8A/$26/>BiosTextAttr { mov AH,[>BiosTextAttr]}
  126.   /$80/$E4/$0F           { and AH,$0F}
  127.   /$08/$E0               { or AL,AH}
  128.   /$A2/>BiosTextAttr);   { mov [>BiosTextAttr],AL}
  129.  
  130. function GetBiosTextAttr:integer;      {Get the current Bios text Attribute}
  131. Inline(
  132.    $B7/$00     { mov BH,0}
  133.   /$B4/$08     { mov AH,8}
  134.   /$55         { push BP}
  135.   /$CD/$10     { int $10}
  136.   /$5D         { pop BP}
  137.   /$88/$E0     { mov AL,AH}
  138.   /$30/$E4);   { xor AH,AH}
  139.  
  140. procedure SetBiosWriteMode(Mode:integer);       {Set Bios write mode to use}
  141. inline(                                         {0=Reg, 1=Xor, 2=Bk}
  142.    $58                   { pop AX}
  143.   /$A2/>BiosWriteMode);  { mov [>BiosWriteMode],AL}
  144.  
  145. procedure SetBiosPage(Page:integer);            {set active bios video page}
  146. inline(
  147.    $58         { pop AX}
  148.   /$B4/$05     { mov AH,5}
  149.   /$55         { push BP}
  150.   /$CD/$10     { int $10}
  151.   /$5D);       { pop BP}
  152.  
  153. procedure BiosCursorOFF;                            {turn the cursor off}
  154. inline(
  155.    $B4/$03     { mov AH,3}
  156.   /$55         { push BP}
  157.   /$CD/$10     { int $10}
  158.   /$5D         { pop BP}
  159.   /$80/$CD/$20 { or ch,$20}
  160.   /$B4/$01     { mov AH,1}
  161.   /$55         { push BP}
  162.   /$CD/$10     { int $10}
  163.   /$5D);       { pop BP}
  164.  
  165. procedure BiosCursorON;                              {turn the cursor on}
  166. inline(
  167.    $B4/$03     { mov AH,3}
  168.   /$55         { push BP}
  169.   /$CD/$10     { int $10}
  170.   /$5D         { pop BP}
  171.   /$80/$E5/$1F { and CH,$1F}
  172.   /$B4/$01     { mov AH,1}
  173.   /$55         { push BP}
  174.   /$CD/$10     { int $10}
  175.   /$5D);       { pop BP}
  176.  
  177. {++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  178. {-- The following are the string procedures to access the BIOS routines ---}
  179.  
  180. procedure BiosWrite(S:String);                       {Bios based text write}
  181. procedure BiosWriteLn(S:String);                   {Bios based text writeln}
  182.  
  183. procedure BiosClrEol;                                 {clear to end of line}
  184. procedure BiosClrScr;                                     {clear the screen}
  185. procedure BiosLowVideo;                  {turns off high intensity attr bit}
  186. procedure BiosHighVideo;                  {turns on high intensity attr bit}
  187. procedure BiosNormalVideo;           {restores video attr to start up value}
  188. procedure A